Week 2 - Exercise 2

Luca Y. Kogelheide

13 Jan 2025

Welcome!

Utrecht University Logo

Welcome to my advanced Quarto presentation!

Interactive Table

library(DT)
datatable(mtcars, options = list(pagelength = 5, scrollX = TRUE))

Interactive Figure

library(ggplot2)
library(plotly)

p <- ggplot(mpg, aes(displ, hwy, color = class)) +
  geom_point()

ggplotly(p)

Two-Column Slide

Column 1

  • Point A
  • Point B

Column 2

  • Point C
  • Point D

Lincoln-Peterson estimator

The Lincoln-Peterson estimator is defined as: \[\begin{aligned} \hat{\theta}^{\text{LP}} &= \frac{n_{1}n_{2}}{m}, \\ \text{where,} \\ n_{1} &= \sum_{i=1}^{r} \left(w_{i} \sum_{j=1}^{7} \delta_{i,j}^{\text{svy}} \right) = \hat{\theta}^{\text{svy}}, \\ n_{2} &= \sum_{i=1}^{r} \left(w_{i} \sum_{j=1}^{7} \delta_{i,j}^{\text{sen}} \right), \\ m &= \sum_{i=1}^{r} \left(w_{i} \sum_{j=1}^{7} \delta_{i,j}^{\text{svy}} \cdot \delta_{i,j}^{\text{sen}} \right). \end{aligned}\]

Statistical inference as severe testing: How to get beyong the statistics wars

I am currently reading a very interesting book by Deborah (Mayo 2018)

displayed, not executed

summary(mtcars)

Cached R code

x <- 1:10
mean(x)
[1] 5.5

Executed, not displayed

Renv

library(renv)
renv::init()

library(tidyverse)
###this is the code for a Lincoln-Peterson estimator:
set.seed(1337)

# Set a population size
popSize = 1000

# simulate a population and three samples
A = rbinom(popSize,1,prob=0.5)
B = rbinom(popSize,1,prob=0.4)
freq = 1
data = cbind(A,B,freq)
observed = nrow(data[rowSums(data[,1:2])!=0,])
m00  = popSize - observed
m00
[1] 305
cont_2S = aggregate(freq~A+B,data=data,FUN=sum)
###LP-estimator for m00
cont_2S[cont_2S$A==1&cont_2S$B==0,"freq"]*
cont_2S[cont_2S$A==0&cont_2S$B==1,"freq"]/
cont_2S[cont_2S$A==1&cont_2S$B==1,"freq"]
[1] 285.3786
sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] lubridate_1.9.3 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4    
 [5] purrr_1.0.2     readr_2.1.5     tidyr_1.3.1     tibble_3.2.1   
 [9] tidyverse_2.0.0 plotly_4.10.4   ggplot2_3.5.1   DT_0.33        

loaded via a namespace (and not attached):
 [1] sass_0.4.9        utf8_1.2.4        generics_0.1.3    renv_1.0.11      
 [5] stringi_1.8.4     hms_1.1.3         digest_0.6.37     magrittr_2.0.3   
 [9] timechange_0.3.0  evaluate_1.0.1    grid_4.4.1        fastmap_1.2.0    
[13] jsonlite_1.8.9    httr_1.4.7        fansi_1.0.6       crosstalk_1.2.1  
[17] viridisLite_0.4.2 scales_1.3.0      lazyeval_0.2.2    jquerylib_0.1.4  
[21] cli_3.6.3         rlang_1.1.4       munsell_0.5.1     withr_3.0.2      
[25] cachem_1.1.0      yaml_2.3.10       tools_4.4.1       tzdb_0.4.0       
[29] colorspace_2.1-1  vctrs_0.6.5       R6_2.5.1          lifecycle_1.0.4  
[33] htmlwidgets_1.6.4 pkgconfig_2.0.3   pillar_1.9.0      bslib_0.8.0      
[37] gtable_0.3.6      data.table_1.16.2 glue_1.8.0        xfun_0.49        
[41] tidyselect_1.2.1  rstudioapi_0.17.1 knitr_1.49        farver_2.1.2     
[45] htmltools_0.5.8.1 rmarkdown_2.29    labeling_0.4.3    compiler_4.4.1   

References

Mayo, Deborah G. 2018. Statistical Inference as Severe Testing: How to Get Beyond the Statistics Wars. Cambridge University Press. https://doi.org/10.1017/9781107286184.